import 'package:blog/screens/main_screen.dart';
import 'package:blog/screens/scroll_screen.dart';
import 'package:blog/screens/search_screen.dart';
import 'package:blog/src/generated/models/setting.pb.dart';
import 'package:flutter/material.dart';
import "package:get/get.dart";

import "locator.dart";
import "constants.dart";
import "screens/article_screen.dart";
import "screens/not_found_screen.dart";
import "routes.dart";

void main() async {
  await setupLocator();

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({Key? key}) : super(key: key);

  final notFoundPage = GetPage(name: Routes.notFound, page: () => NotFoundScreen());
  List<GetPage> get pages => [
        GetPage(name: Routes.home, page: () => MainScreen(), children: [
          GetPage(name: Routes.detail, page: () => ArticleScreen()),
          GetPage(name: Routes.search, page: () => SearchScreen()),
          notFoundPage,
          GetPage(name:'/test', page:() => ScrollScreen()),
        ])
      ];

  ThemeData get themeData => ThemeData(
        primaryColor: kPrimaryColor,
        scaffoldBackgroundColor: kBgColor,
        elevatedButtonTheme: ElevatedButtonThemeData(
          style: TextButton.styleFrom(backgroundColor: kPrimaryColor),
        ),
        textTheme: TextTheme(
          bodyText1: TextStyle(color: kBodyTextColor),
          bodyText2: TextStyle(color: kBodyTextColor),
          headline5: TextStyle(color: kDarkBlackColor),
        ),
      );

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: locator<SiteSetting>().title,
      debugShowCheckedModeBanner: false,
      theme: themeData,
      home: MainScreen(),
      getPages: pages,
      unknownRoute: notFoundPage,
    );
  }
}
